#! /usr/bin/env python
#coding: utf-8

import threading
import time
from Queue import Queue

queue = Queue()

def Create(i):
	while True:
		if queue.qsize() < 100:
			print i,'生产包子'
			queue.put(str(i) + '包子' )
		else:
			time.sleep(5)
def Producer():
	for i in range(3):
		t = threading.Thread(target=Create,args=(i,))
		t.start()

def consummer():
	while True:
		baozi = queue.get()
		print '取走' ,baozi,',剩余' ,queue.qsize() 
		time.sleep(1)


Producer()
consummer()